#ifndef DATETIMEEDITDELEGATE_H
#define DATETIMEEDITDELEGATE_H

#include <QDateTime>
#include <QStyledItemDelegate>

class QDateTimeEdit;

class DateTimeEditDelegate : public QStyledItemDelegate
{
    Q_OBJECT
public:
    explicit DateTimeEditDelegate(QObject *parent = 0);

    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    void setEditorData(QWidget *editor, const QModelIndex &index) const;
    void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;

public slots:
    void setDefaultDateTime (QDateTime dateTime);
    void setDisplayFormat (QString format);
    void setCurrentDateTimeAsDefault (bool enabled);

private slots:
    void setSelectedSection (QDateTimeEdit* dateTimeEdit);

private:
    mutable QDateTime m_oldValue;
    QDateTime m_defaultDateTime;
    QString m_displayFormat;
    bool m_currentDateTimeAsDefault;
};

#endif // DATETIMEEDITDELEGATE_H
